package com.sy.server.mapper;

import com.sy.server.model.Feedback;
import com.sy.server.model.FeedbackExample;
import java.util.List;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

public interface FeedbackMapper {
    @SelectProvider(type=FeedbackSqlProvider.class, method="countByExample")
    int countByExample(FeedbackExample example);

    @DeleteProvider(type=FeedbackSqlProvider.class, method="deleteByExample")
    int deleteByExample(FeedbackExample example);

    @Delete({
        "delete from feedback",
        "where f_id = #{fId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer fId);

    @Insert({
        "insert into feedback (f_id, f_user_id, ",
        "send_time, likes, ",
        "anonymous, content)",
        "values (#{fId,jdbcType=INTEGER}, #{fUserId,jdbcType=INTEGER}, ",
        "#{sendTime,jdbcType=TIMESTAMP}, #{likes,jdbcType=BIGINT}, ",
        "#{anonymous,jdbcType=TINYINT}, #{content,jdbcType=LONGVARCHAR})"
    })
    int insert(Feedback record);

    @InsertProvider(type=FeedbackSqlProvider.class, method="insertSelective")
    int insertSelective(Feedback record);

    @SelectProvider(type=FeedbackSqlProvider.class, method="selectByExampleWithBLOBs")
    @Results({
        @Result(column="f_id", property="fId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="f_user_id", property="fUserId", jdbcType=JdbcType.INTEGER),
        @Result(column="send_time", property="sendTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="likes", property="likes", jdbcType=JdbcType.BIGINT),
        @Result(column="anonymous", property="anonymous", jdbcType=JdbcType.TINYINT),
        @Result(column="content", property="content", jdbcType=JdbcType.LONGVARCHAR),
            @Result(column = "f_user_id",property = "user",one=@One(
                    select = "com.sy.server.mapper.UserMapper.selectByPrimaryKey"
            ))
    })
    List<Feedback> selectByExampleWithBLOBs(FeedbackExample example);

    @SelectProvider(type=FeedbackSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="f_id", property="fId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="f_user_id", property="fUserId", jdbcType=JdbcType.INTEGER),
        @Result(column="send_time", property="sendTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="likes", property="likes", jdbcType=JdbcType.BIGINT),
        @Result(column="anonymous", property="anonymous", jdbcType=JdbcType.TINYINT)
    })
    List<Feedback> selectByExample(FeedbackExample example);

    @Select({
        "select",
        "f_id, f_user_id, send_time, likes, anonymous, content",
        "from feedback",
        "where f_id = #{fId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="f_id", property="fId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="f_user_id", property="fUserId", jdbcType=JdbcType.INTEGER),
        @Result(column="send_time", property="sendTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="likes", property="likes", jdbcType=JdbcType.BIGINT),
        @Result(column="anonymous", property="anonymous", jdbcType=JdbcType.TINYINT),
        @Result(column="content", property="content", jdbcType=JdbcType.LONGVARCHAR)
    })
    Feedback selectByPrimaryKey(Integer fId);

    @UpdateProvider(type=FeedbackSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Feedback record, @Param("example") FeedbackExample example);

    @UpdateProvider(type=FeedbackSqlProvider.class, method="updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") Feedback record, @Param("example") FeedbackExample example);

    @UpdateProvider(type=FeedbackSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Feedback record, @Param("example") FeedbackExample example);

    @UpdateProvider(type=FeedbackSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Feedback record);

    @Update({
        "update feedback",
        "set f_user_id = #{fUserId,jdbcType=INTEGER},",
          "send_time = #{sendTime,jdbcType=TIMESTAMP},",
          "likes = #{likes,jdbcType=BIGINT},",
          "anonymous = #{anonymous,jdbcType=TINYINT},",
          "content = #{content,jdbcType=LONGVARCHAR}",
        "where f_id = #{fId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKeyWithBLOBs(Feedback record);

    @Update({
        "update feedback",
        "set f_user_id = #{fUserId,jdbcType=INTEGER},",
          "send_time = #{sendTime,jdbcType=TIMESTAMP},",
          "likes = #{likes,jdbcType=BIGINT},",
          "anonymous = #{anonymous,jdbcType=TINYINT}",
        "where f_id = #{fId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Feedback record);

    @Update({
            "update feedback",
            "set likes = #{likes,jdbcType=BIGINT}",
            "where f_id = #{fId,jdbcType=INTEGER}"
    })
    int updateLikesByPrimaryKey(Feedback feedback);
}